package com.sbm.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

// REST风格控制器
@RestController
public class HelloController {

    /**
     * 控制器方法
     * @param name 姓名
     * @return 视图和模型，指向Thymeleaf模板
     */
    @GetMapping("/hello/{name}")
    public ModelAndView sayHello(@PathVariable("name") String name) {
        ModelAndView mav =new ModelAndView("hello");
        mav.addObject("name", name);
        return mav;
    }
}
